home *** CD-ROM | disk | FTP | other *** search
- /*
- ** AREXX $VER: Start_TeX.ced V1.45 (27.07.1995)
- **
- ** This AREXX script saves and compiles the current CED Pro 2 view. The only
- ** (optional) argument is the format to be used. A '?' formatname will
- ** interactively ask for the format to use.
- **
- ** A command is send to the TeX server to compile the file. Hence a return
- ** value of 0 does not mean that the file compiled well, but only that the
- ** command was sent to the server and replied to.
- **
- ** AUTHOR: J\"org H\"ohle, March 91
- **
- ** BUGS: virtex doesn't like filenames with blanks (and ARexx parses them
- ** hardly too), so avoid them in file, directory *and* device names.
- **
- ** Does not like names relative to the local root, like ":foo/bar".
- **
- ** CED views may have negative change counts, so test for `equal zero'.
- **
- ** FILES: ENV:TEXFORMAT default format used
- ** REXX:NameStruc
- **
- ** CHANGES: 22.04.1994: Quit processing when format selection `cancel'led.
- ** 23.09.1994: Standard LaTeX2e format is called `latex'.
- ** 27.07.1995: Start the TeX Server when not already running.
- */
-
- Options Results
-
- PORTNAME = 'Start_TeX'
- SCRIPT = 'TeX-server.rexx' /* no path required, message only */
-
- /*
- ** 1: Ask interactively for format name
- ** 0: Don't
- */
- If "" = GetClip("TEXQUERY") Then
- ASKFORMAT = 0
- Else
- ASKFORMAT = 1
-
- Parse Arg FORMAT .
- If "?" = FORMAT Then Do
- ASKFORMAT = 1
- FORMAT = ""
- End; Else If '&' = Left(FORMAT,1) Then
- FORMAT = SubStr(FORMAT,2)
-
- /*
- ** Get the full filename from CED
- */
- Status 19
- FULLNAME = RESULT
-
- /*
- ** We need an absolute name
- */
- Parse Value NameStruc(FULLNAME) With IVOL IDIRS IBASE .
-
- /*
- ** Do we really have a TeX input file?
- */
- If "" = SubStr(FULLNAME,1+IVOL+IDIRS+IBASE) | Upper(Right(FULLNAME,3)) ~= "TEX" Then Do
-
- /*
- ** Or is it a LateX input file? Then change the FORMAT.
- */
- If "" = SubStr(FULLNAME,1+IVOL+IDIRS+IBASE) | Upper(Right(FULLNAME,3)) ~= "LTX" Then Do
- Okay1 "Fehler, die Datei muß eine Endung `.tex' oder `.ltx' haben."
- Exit 5
- End; Else Do
- If ASKFORMAT = 1 Then
- FORMAT = ""
- Else
- FORMAT = 'latex'
- End
- End
-
- If 0 = IVOL Then Do
- DIREC = Pragma('d')
- If Right(DIREC,1) ~= '/' & Right(DIREC,1) ~= ':' Then
- DIREC = DIREC||'/'
- FULLNAME = DIREC||FULLNAME
- Drop DIREC
- End
- Drop IVOL IDIRS IBASE
-
- /*
- ** Save only if file has been modified.
- ** So get the number of changes to the file.
- */
- Status 18
- If 0 ~= RESULT Then
- Save
-
- /*
- ** Start the TeX Server before the current job, when it is not
- ** already running. There is a little timing problem to be solved.
- */
- If ~Show('Port',PORTNAME) Then Do
- Address Command "InitTeX"
- Address Command "WaitForPort Start_TeX"
- End
-
- If Show('Port',PORTNAME) Then Do
- /*
- ** Set the default TEXFORMAT, modify it to suit your needs.
- */
- ENVFORMAT = MyGetEnv("TEXFORMAT")
- If "" = FORMAT Then Do
- FORMAT = ENVFORMAT
- If ASKFORMAT | "" = ENVFORMAT Then Do
- If "" = FORMAT Then
- FORMAT = 'plain'
- 'GetString 'FORMAT '"Welches Format soll benutzt werden?"'
- NFORMAT = RESULT
- /*
- ** "RESULT" if cancelled
- */
- If "RESULT" ~= NFORMAT Then
- FORMAT = NFORMAT
- Else
- Exit
- End /* ASKFORMAT */
- End /* FORMAT */
-
- /*
- ** If the server is already busy with some compilation, this will
- ** wait until the compilation finishes, this may take a long time
- ** because no unlocking (like in MG) is available
- */
- If FORMAT ~= ENVFORMAT Then
- Call MySetEnv("TEXFORMAT",FORMAT)
-
- Address Value PORTNAME
- 'compile' FORMAT FULLNAME
- End; Else Do
- /*
- ** The TeX server must be started first
- */
- Okay1 'Der TeX-Server läuft nicht!'
- Exit 5
- End
-
- Exit
-
- /*
- ** When will Arexx supply GetEnv/SetEnv ?
- */
- MyGetEnv: Procedure
- Parse Arg NAME
-
- If Open(TEMPFILE,"ENV:"||NAME,'r') Then Do
- GIVES = Readln(TEMPFILE)
- Call Close TEMPFILE
- End; Else
- GIVES = ""
-
- Return GIVES
-
- MySetEnv: Procedure
- Parse Arg NAME,CONTENT
-
- Address COMMAND "SetEnv" NAME CONTENT
-
- Return
-